<template>
  <div id="centreRight1">
    <div class="bg-color-black">
      <div class="d-flex pt-2 pl-2">
        <span style="color:#5cd9e8">
          <icon name="chart-area"></icon>
        </span>
        <div class="d-flex">
          <span class="fs-xl text mx-2">房间用电排行榜</span>
        </div>
      </div>
      <dv-decoration-4 :reverse="true" style="width:100%;height:5px;" />
      <div class="d-flex jc-center body-box">
        <dv-scroll-board :config="config" style="width:3.20rem;height:3.98rem" />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    chartData: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      config: {
        header: ["空间", "电量(度)"],
        data: [],
        rowNum: 4, //表格行数
        headerHeight: 35,
        headerBGC: "#0f1325", //表头
        oddRowBGC: "#0f1325", //奇数行
        evenRowBGC: "#171c33", //偶数行
        index: true,
        columnWidth: [50],
        align: ["center"]
      }
    };
  },
  components: {},
  mounted() {},
  methods: {},
  watch: {
    chartData: {
      handler(newData) {
        const places = newData.miniPlaceEnergy
        const data = []
        for(const place of places){
          data.push( [place.name, place.totalPower],)
        }
        this.config =  {
          header: ["空间", "电量(度)"],
          data: data,
          rowNum: 4, //表格行数
          headerHeight: 35,
          headerBGC: "#0f1325", //表头
          oddRowBGC: "#0f1325", //奇数行
          evenRowBGC: "#171c33", //偶数行
          index: true,
          columnWidth: [50],
          align: ["center"]
        }
      },
      immediate: true,
      deep: true
    }
  }
};
</script>

<style lang="scss">
#centreRight1 {
  padding: 0.2rem;
  height: 5.125rem;
  min-width: 3.75rem;
  border-radius: 0.0625rem;
  .bg-color-black {
    height: 4.8125rem;
    border-radius: 0.125rem;
  }
  .text {
    color: #c3cbde;
  }
  .body-box {
    border-radius: 0.125rem;
    overflow: hidden;
  }
}
</style>
